<template>
   <div>
    <thead>
      <tr>
        <th>商品名</th>
        <th>价格</th>
        <th>数量</th>
        <th>小计</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="item in list" v-bind:key="item.id">
        <td>{{ item.name }}</td>
        <td>{{ item.price }}</td>
        <td>
          <button
            v-bind:disabled="item.num == 0"
            v-on:click="$emit('changeNum',-1,item.id)"
          >
            -
          </button>
          {{ item.num }}
          <button v-on:click="$emit('changeNum',1,item.id)">+</button>
        </td>
        <td>{{ item.price * item.num }}</td>
        <td><button v-on:click="$emit('del',item.id)">删除</button></td>
      </tr>
    </tbody>
    <tfoot>
      总价：{{
        total
      }}
    </tfoot>
  </div>
</template>

<script>
export default {
    props:["list","total"]

}
</script>

<style>

</style>